可使用AudioManager来让系统静音。
http://www.pocketdigi.com/20110717/398.html
亮点:
首先是步进的方法:
public void adjustStreamVolume (int streamType, int direction, int flags)
1 |
am.adjustStreamVolume (AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI ) ; |
解释一下三个参数
第一个streamType是需要调整音量的类型,这里设的是媒体音量,可以是:
STREAM_ALARM 警报
STREAM_MUSIC 音乐回放即媒体音量
STREAM_NOTIFICATION 窗口顶部状态栏Notification,
STREAM_RING 铃声
STREAM_SYSTEM 系统
短裙诱惑
HxLauncher: Launch Android applications by voice commands